package com.east.utils;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

import org.bouncycastle.jcajce.provider.asymmetric.dsa.DSASigner.stdDSA;

import net.sf.json.JSONObject;
/**
 * 数据处理
 * @author Administrator
 *
 */
public class DataProess{
	/**
	 * 公共方法  封装数据
	 * @param list
	 * @param className
	 * @return
	 * @throws NoSuchMethodException
	 * @throws SecurityException
	 * @throws IllegalAccessException
	 * @throws IllegalArgumentException
	 * @throws InvocationTargetException
	 */
	public static List<Integer> proessing(List<?> list,String className) throws Exception {
		String getMethodName="get"+className.substring(0, 1).toUpperCase()+className.substring(1);
		List<Integer> lists=new ArrayList<Integer>();
		for (Object sc : list) {
			Method method = sc.getClass().getMethod(getMethodName, new Class[] {});
			JSONObject invoke = JSONObject.fromObject(method.invoke(sc)) ;
			if(invoke!=null) {
				lists.add(invoke.getInt("id"));
			}
		}
		return lists;
	}
	
}
